package com.kgc.mj.springbooot.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * Created by MJ on 2020/10/21 9:33
 */
@Service
public class AsyncChargeServiceImpl implements AsyncChargeService {
    private static final Logger logger = LoggerFactory.getLogger(AsyncChargeServiceImpl.class);

    @Override
    @Async("asyncServiceExecutor")
    public void executeAsyncCharge(String phoneNo) {
        logger.info("========" + phoneNo + ",开始充值=======");
        long currentTimeStart = System.currentTimeMillis();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            logger.error("充值异常。异常信息为" + e.getMessage());
        }
        long currentTimeEnd = System.currentTimeMillis();
        logger.info("========充值耗时" + (currentTimeEnd - currentTimeStart) + ",=======");
        logger.info("========" + phoneNo + "充值完成");
    }
}
